<?php
class Mcity extends CI_Model{
	function __construct(){
		parent::__construct();
	}
	function getById($id){
		$sql = "select *
				from tbcity
				where id= ?";
		$query = $this->db->query($sql,array("$id"));
		$arr=array();
		foreach ($query->result() as $row){
			$arr[$row->id]=$row->name;
		}
		return $arr;
	}
	function getAll(){
		$sql = "select *
				from tbcity
				order by id";
		$query = $this->db->query($sql);
		$arr=array();
		foreach ($query->result() as $row){
			$arr[$row->id]=$row->name;
		}
		return $arr;
	}
	function getByProvinceId($provinceId){
		$sql = "select *
				from tbcity
				where provinceid = ?";
		$query = $this->db->query($sql,array("$provinceId"));
		$arr=array();
		foreach ($query->result() as $row){
			$arr[$row->id]=$row->name;
		}
		return $arr;
	}
	
}
?>